//
//  PublishReoprtPopVC.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/27.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "PublishReoprtPopVC.h"
#import "AppDelegate.h"
#import "CommonMacro.h"
@interface PublishReoprtPopVC ()
@property (nonatomic,strong) UIWindow *window;
@property (nonatomic,strong) UIView *bgView;
@property (nonatomic,strong) UIView *showView;
@property (nonatomic,strong) UILabel *textLabel;
@property (nonatomic,strong) UILabel *scoreLabel;
@property (nonatomic,strong) UIButton *exitButton;
@property (nonatomic,strong) UIView *middleView;
@end

@implementation PublishReoprtPopVC

static NSString * const reuseIdentifier = @"Cell";

- (void)viewDidLoad {
    [super viewDidLoad];
   
}

- (void)publishReportPopView
{
    self.window=[[UIApplication sharedApplication].delegate window];
    self.bgView=[[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.bgView.backgroundColor = [UIColor blackColor];
    self.bgView.alpha=0.5;
    [self.window addSubview:self.bgView];
    
    self.middleView = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH*0.06, -SCREEN_HEIGHT, SCREEN_WIDTH*0.86, SCREEN_HEIGHT*0.4)];
    [self.window addSubview:self.middleView];
//    self.middleView.backgroundColor = [UIColor whiteColor];
    

    self.showView = [[UIView alloc] initWithFrame:CGRectMake(self.middleView.frame.size.width*0.05, self.middleView.frame.size.height*0.1, self.middleView.frame.size.width*0.9, self.middleView.frame.size.height*0.77)];
    [self.middleView addSubview:self.showView];
    self.showView.backgroundColor = [UIColor whiteColor];
    self.showView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"弹窗"]];
    self.showView.layer.cornerRadius = 3;
    self.showView.clipsToBounds = YES;
    [self addWithSubviews];
    
    self.exitButton = [[UIButton alloc] initWithFrame:CGRectMake(self.showView.frame.size.width+self.showView.frame.origin.x-15, self.showView.frame.origin.y-10, self.showView.frame.size.width*0.13, self.showView.frame.size.width*0.13)];
    [self.middleView addSubview:self.exitButton];
    [self.exitButton setBackgroundImage:[UIImage imageNamed:@"叉号"] forState:UIControlStateNormal];
    [self.exitButton addTarget:self action:@selector(dismissClick) forControlEvents:UIControlEventTouchUpInside];
    
    //给bview一个动画
    [UIView animateWithDuration:0.5 animations:^{
        self.middleView.center=self.window.center;
    }];

}

- (void)addWithSubviews
{
    self.scoreLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.showView.frame.size.width*0.2, 10, self.showView.frame.size.width*0.6, self.showView.frame.size.height*0.17)];
    [self.showView addSubview:self.scoreLabel];
    self.scoreLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"黄色框"]];
    self.scoreLabel.textColor = UIColorWithRGBA(255, 255, 255, 1);
    self.scoreLabel.font = [UIFont boldSystemFontOfSize:18];
    self.scoreLabel.text = @"积分+15";
    self.scoreLabel.textAlignment = NSTextAlignmentCenter;
    self.scoreLabel.layer.cornerRadius = 5;
    self.scoreLabel.clipsToBounds = YES;
    
    self.textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.showView.frame.size.height*0.78, self.showView.frame.size.width, self.showView.frame.size.height*0.3)];
    [self.showView addSubview:self.textLabel];
    self.textLabel.text = @"恭喜!发布成功";
    self.textLabel.textColor = UIColorWithRGBA(255, 255, 255, 1);
    self.textLabel.font = [UIFont boldSystemFontOfSize:14];
    self.textLabel.textAlignment = NSTextAlignmentCenter;
}

#pragma  mark 移除
- (void)dismissClick
{
    [UIView animateWithDuration:0.5 animations:^{
        self.middleView.frame=CGRectMake(SCREEN_WIDTH*0.06, SCREEN_HEIGHT, SCREEN_WIDTH*0.86, SCREEN_HEIGHT*0.4);
    } completion:^(BOOL finished) {
        [self.bgView removeFromSuperview];
        [self.middleView removeFromSuperview];
    }];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}


@end
